import Vue from "vue";
import Router from "vue-router";
import Login from "@/pages/Login";
import Register from "@/pages/Register";
import Warning from "@/pages/Warning";
import Show from "@/components/Show";
import Index from "@/pages/Index";
import Self from "@/pages/Self";
import Friend from "@/pages/Friend";
import FollowDynamic from "@/pages/FollowDynamic";
import AdminShow from "@/components/AdminShow";
import AdminLogin from "@/pages/AdminLogin";
import ManageDynamic from "@/pages/ManageDynamic";
import ManageUser from "@/pages/ManageUser";
import ManageDoctor from "@/pages/ManageDoctor";
import DiabetesPrediction from "@/pages/DiabetesPrediction";
import Team from "@/pages/Team";


const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router);


export default new Router({
    routes: [
        {
            path: '/',
            name: '/',
            component: Login
        },
        {
            path: '/adminLogin',
            component: AdminLogin
        },
        {
            path: '/register',
            name: 'register',
            component: Register
        },
        {
            path: '/warning',
            name: 'warning',
            component: Warning
        },
        {
            path: '/show',
            name: 'show',
            component: Show,
            redirect: '/index',
            children: [
                {
                    path: '/index',
                    name: 'index',
                    component: Index
                },
                {
                    path: '/self',
                    component: Self
                },
                {
                    path: '/friend',
                    component: Friend
                },
                {
                    path: '/followDynamic',
                    component: FollowDynamic
                },
                {
                    path: '/diabetesPrediction',
                    component: DiabetesPrediction
                },
                {
                    path: '/team',
                    component: Team
                }
            ]
        },
        {
            path: '/adminShow',
            name: 'adminShow',
            component: AdminShow,
            redirect: '/manageDynamic',
            children: [
                {
                    path: '/manageDynamic',
                    component: ManageDynamic
                },
                {
                    path: '/manageUser',
                    component: ManageUser
                },
                {
                    path: '/manageDoctor',
                    component: ManageDoctor
                }
            ]
        },
    ]
});